package com.doctor.web.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.doctor.web.domain.ProductDO;
import com.doctor.web.mapper.ProductMapper;
import com.doctor.web.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ProductServiceImpl implements ProductService {

    @Autowired
    private ProductMapper productMapper;

    @Override
    public boolean save(ProductDO productDO) {
        return productMapper.save(productDO) > 0;
    }

    @Override
    public boolean removeById(Long id) {
        return productMapper.removeById(id) > 0;
    }

    @Override
    public boolean updateById(ProductDO productDO) {
        return productMapper.updateById(productDO) > 0;
    }

    @Override
    public List<ProductDO> getProductList() {
        return productMapper.getProductList();
    }

    @Override
    public List<ProductDO> getProductsByCategory(Integer categoryName) {
        return productMapper.getProductsByCategory(categoryName);
    }

    @Override
    public List<ProductDO> getProductsSortedBySalesDesc() {
        return productMapper.getProductsSortedBySalesDesc();
    }

    @Override
    public List<ProductDO> getProductsSortedByPriceAsc() {
        return productMapper.getProductsSortedByPriceAsc();
    }

    @Override
    public List<ProductDO> getProductsSortedByPriceDesc() {
        return productMapper.getProductsSortedByPriceDesc();
    }

    @Override
    public ProductDO getById(Long id) {
        return productMapper.getById(id);
    }
}